﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace GMusicBox.Core.Setting
{
    public class LyricShowSetting
    {
        public static Settings Data { get; set; }
        public static string FileName { get { return Settings.SettingSavePath + "\\Config\\Configs\\LyricShow.xml"; } }
        public static void Update() { Data = new Settings(FileName); }
        public static void Save() { Data.WriteAllSettings(FileName); }

        public static Color DBackColor
        {
            get
            {
                string data = Data["DBackColor"];
                if (data == "")
                    return Color.FromArgb(128, 128, 128);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["DBackColor"] = Helper.Color2String(value);
            }
        }

        public static Color DBorderColor
        {
            get
            {
                string data = Data["DBorderColor"];
                if (data == "")
                    return Color.FromArgb(0, 0, 0);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["DBorderColor"] = Helper.Color2String(value);
            }
        }

        public static string DFont
        {
            get
            {
                string data = Data["DFont"];
                if (data == "")
                    return "幼圆,25,1";
                else return data;
            }
            set
            {
                Data["DFont"] = value;
            }
        }

        public static bool DKalaOK
        {
            get
            {
                string data = Data["DKalaOK"];
                if (data == "")
                    return true;
                else return bool.Parse(data);
            }
            set
            {
                Data["DKalaOK"] = value.ToString();
            }
        }

        public static int DLinearMode
        {
            get
            {
                string data = Data["DLinearMode"];
                if (data == "")
                    return 0;
                else return int.Parse(data);
            }
            set
            {
                Data["DLinearMode"] = value.ToString();
            }
        }

        public static Color DHTextColor
        {
            get
            {
                string data = Data["DHTextColor"];
                if (data == "")
                    return Color.FromArgb(255, 255, 0);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["DHTextColor"] = Helper.Color2String(value);
            }
        }

        public static Color DHTextColor1
        {
            get
            {
                string data = Data["DHTextColor1"];
                if (data == "")
                    return Color.FromArgb(255, 232, 137);
                else
                {
                    string[] s = data.Split(',');
                    return Color.FromArgb(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]));
                }
            }
            set
            {
                Data["DHTextColor1"] = Helper.Color2String(value);
            }
        }

        public static double DOpacity
        {
            get
            {
                string data = Data["DOpacity"];
                if (data == "")
                    return 1;
                else if (data[data.Length - 1] == '%')
                {
                    data = data.Substring(0, data.Length - 1);
                    return double.Parse(data) / 100;
                }
                else return double.Parse(data);
            }
            set
            {
                Data["DOpacity"] = value.ToString();
            }
        }

        public static Color DTextColor
        {
            get
            {
                string data = Data["DTextColor"];
                if (data == "")
                    return Color.FromArgb(144, 210, 248);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["DTextColor"] = Helper.Color2String(value);
            }
        }

        public static Color DTextColor1
        {
            get
            {
                string data = Data["DTextColor1"];
                if (data == "")
                    return Color.FromArgb(55, 137, 221);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["DTextColor1"] = Helper.Color2String(value);
            }
        }
        
        public static Color LBackColor
        {
            get
            {
                string data = Data["LBackColor"];
                if (data == "")
                    return Color.FromArgb(255, 255, 255);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["LBackColor"] = Helper.Color2String(value);
            }
        }

        public static bool LFade
        {
            get
            {
                string data = Data["LFade"];
                if (data == "")
                    return true;
                else return bool.Parse(data);
            }
            set { Data["LFade"] = value.ToString(); }
        }

        public static string LFont
        {
            get
            {
                string data = Data["LFont"];
                if (data == "")
                    return "宋体,9,0";
                else return data;
            }
            set { Data["LFont"] = value; }
        }

        public static Color LHTextColor
        {
            get
            {
                string data = Data["LHTextColor"];
                if (data == "")
                    return Color.FromArgb(0, 0, 0);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["LHTextColor"] = Helper.Color2String(value);
            }
        }

        public static Color LTextColor
        {
            get
            {
                string data = Data["LTextColor"];
                if (data == "")
                    return Color.FromArgb(153, 153, 153);
                else return Helper.String2Color(data);
            }
            set
            {
                Data["LTextColor"] = Helper.Color2String(value);
            }
        }
    }
}
